//
//  TravelCollectionViewCell.m
//  B
//
//  Created by Znt on 15/11/7.
//  Copyright © 2015年 wangzhan. All rights reserved.
//

#import "TravelCollectionViewCell.h"
#import "Model4.h"
@implementation TravelCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
        
    }
    return self;
}

- (void)createSubViews{
    self.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1];
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 5;
    self.photo = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 0   , 0)];
    [self.contentView addSubview:self.photo];
    
    self.text = [[UILabel alloc]initWithFrame:CGRectMake(self.photo.x, self.photo.height ,0,0)];
    self.text.numberOfLines = 0;
    [self addSubview:self.text];
    
    self.local_time = [[UILabel alloc]initWithFrame:CGRectMake(self.text.x, 0, self.contentView.width * 0.3, self.contentView.height * 0.1)];
    self.local_time.textColor = [UIColor lightGrayColor];
    self.local_time.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.local_time];
    
    self.local = [[UILabel alloc]init];
    self.local.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.local];
    
//    self.shadow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"journey_cell_shadow"]];
//    [self addSubview:self.shadow];
//    
//    self.photo_bottom_cover = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"destination_detail_photo_bottom_cover"]];
//    [self addSubview:self.photo_bottom_cover];
    
    self.clock = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"clock_gray_big"]];
    [self addSubview:self.clock];
}

- (void)setModel4:(Model4 *)model{
    if (_model4 != model) {
        _model4 = model;
    }
    
    
    
    
    [self.photo sd_setImageWithURL:[NSURL URLWithString: _model4.photo_1600 ] placeholderImage:nil];
    
    if (_model4.photo_1600 != nil) {
        self.photo.frame = CGRectMake(0, 0, 375 *XWIDTH, 360 * XHIGHT);
    } else {
        
        self.photo.frame = CGRectMake(0, 0, 0, 0);
    }
    
    self.text.text =_model4.text;
    CGFloat height =  [AppTools heightForCell:_model4.text andFont:15];
    self.text.frame = CGRectMake(0, self.photo.frame.size.height, 375 * XWIDTH, height *XHIGHT);
    self.clock.frame = CGRectMake(self.text.frame.origin.x, self.text.frame.origin.y + self.text.frame.size.height, 15 *XWIDTH, 15 *XHIGHT);
    self.local.text = [NSString stringWithFormat:@"%@ %@",model.country,model.city];
    self.local_time.text = _model4.local_time;
    self.local_time.frame = CGRectMake(self.clock.frame.origin.x + 15 *XWIDTH, self.clock.frame.origin.y - 8*XHIGHT, 150 *XWIDTH, 30);
    self.local.frame = CGRectMake(self.local_time.frame.origin.x +200 *XWIDTH, self.local_time.frame.origin.y, 150, 30);
    
    
    
}


@end
